// HSS.Net.Dns.Records.RecordAAAA.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       RecordAAAA.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
using System;

#region Rfc info
/*
2.2 AAAA data format

   A 128 bit IPv6 address is encoded in the data portion of an AAAA
   resource record in network byte order (high-order byte first).
 */
#endregion

namespace HSS.Net.Dns.Records
{
	/// <summary>
	/// An IPv6 Record
	/// </summary>
	[System.CLSCompliant(false)]
	public class RecordAAAA : Record
	{
		/// <summary>
		/// The IPAddress this record represents
		/// </summary>
		public System.Net.IPAddress Address;
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="rr">The resource reader</param>
		public RecordAAAA(RecordReader rr)
		{
			System.Net.IPAddress.TryParse(
				string.Format("{0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}:{6:x}:{7:x}",
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16()), out this.Address);
		}
		/// <summary>
		/// Gets the IPAddress as a string
		/// </summary>
		/// <returns>The IPAddress as a string</returns>
		public override string ToString()
		{
			return Address.ToString();
		}
	}
}